From patchwork Thu Jun 25 09:51:31 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [OpenWrt-Devel,package] grub2: fix musl build
X-Patchwork-Submitter: Dirk Neukirchen <dirkneukirchen@web.de>
X-Patchwork-Id: 488325
X-Patchwork-Delegate: jow@openwrt.org
Message-Id: <558BCF23.40304@web.de>
To: OpenWrt Development List <openwrt-devel@lists.openwrt.org>
Date: Thu, 25 Jun 2015 11:51:31 +0200
From: Dirk Neukirchen <dirkneukirchen@web.de>
List-Id: OpenWrt Development List <openwrt-devel.lists.openwrt.org>

fixes compile error:
grub-core/osdep/unix/hostdisk.c: In function 'grub_util_fd_seek':
grub-core/osdep/unix/hostdisk.c:89:14: error: invalid storage class for function '_llseek'
   static int _llseek (uint filedes, ulong hi, ulong lo,

Signed-off-by: Dirk Neukirchen <dirkneukirchen@web.de>
---
 package/boot/grub2/patches/001-grub-musl.patch | 47 ++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/boot/grub2/patches/001-grub-musl.patch

diff --git a/package/boot/grub2/patches/001-grub-musl.patch b/package/boot/grub2/patches/001-grub-musl.patch
new file mode 100644
index 0000000..daba87f
--- /dev/null
+++ b/package/boot/grub2/patches/001-grub-musl.patch
@@ -0,0 +1,47 @@
+--- a/grub-core/osdep/unix/hostdisk.c
++++ b/grub-core/osdep/unix/hostdisk.c
+@@ -48,11 +48,6 @@
+ #ifdef __linux__
+ # include <sys/ioctl.h>         /* ioctl */
+ # include <sys/mount.h>
+-# if !defined(__GLIBC__) || \
+-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
+-/* Maybe libc doesn't have large file support.  */
+-#  include <linux/unistd.h>     /* _llseek */
+-# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
+ #endif /* __linux__ */
+ 
+ grub_uint64_t
+@@ -79,24 +74,6 @@ grub_util_get_fd_size (grub_util_fd_t fd
+   return st.st_size;
+ }
+ 
+-#if defined(__linux__) && (!defined(__GLIBC__) || \
+-        ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
+-  /* Maybe libc doesn't have large file support.  */
+-int
+-grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
+-{
+-  loff_t offset, result;
+-  static int _llseek (uint filedes, ulong hi, ulong lo,
+-		      loff_t *res, uint wh);
+-  _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
+-	     loff_t *, res, uint, wh);
+-
+-  offset = (loff_t) off;
+-  if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
+-    return -1;
+-  return GRUB_ERR_NONE;
+-}
+-#else
+ int
+ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
+ {
+@@ -107,7 +84,6 @@ grub_util_fd_seek (grub_util_fd_t fd, gr
+ 
+   return 0;
+ }
+-#endif
+ 
+ 
+ /* Read LEN bytes from FD in BUF. Return less than or equal to zero if an
